﻿@model System.Guid
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
    <title></title>
    <link href="/Contents/css/datagridtop.css" rel="stylesheet" type="text/css" />
    <script src="/Contents/scripts/jquery-1.8.0.min.js"type="text/javascript"></script>
    <script src="/Contents/scripts/jquery-easyui-1.3.2/jquery.easyui.min.js"type="text/javascript"></script>
    <link href="/Contents/scripts/jquery-easyui-1.3.2/themes/default/easyui.css"rel="stylesheet" type="text/css" />
    <link href="/Contents/scripts/jquery-easyui-1.3.2/themes/icon.css" rel="stylesheet"type="text/css" />
    <script src="/Contents/scripts/jquery-easyui-1.3.2/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>
    <script src="/Contents/scripts/shadeform/script/form.js" type="text/javascript"></script>
    <link href="/Contents/scripts/shadeform/style/formsytle.css" rel="stylesheet"type="text/css" />
    <link href="/Contents/css/common.css" rel="stylesheet" type="text/css" />
</head>
<body style="background: none; padding-left: 15px; padding-right: 15px; padding-top: 2px;
    text-align: center;">
    <div class="GridTablesTop" id="biaotouwidth" style="width: 100%; padding-bottom: 10px;">
        <span class="spl">
            <strong><span>案例分析选择题列表</span></strong>
        </span>
    </div>
    <table id="dg_choice" ></table>
    <script type="text/javascript">
        $(function () {
            var toolbar_choice = [{
                text: '添加选择题',
                iconCls: 'icon-add',
                handler: function () { showAddChoiceForm("@Model.ToString()"); }
            }];
            $('#dg_choice').datagrid({
                width: parseFloat(document.getElementById("biaotouwidth").clientWidth),
                striped: true,
                loading: true,
                loadMsg: "正在加载数据,请稍等...",
                idField: 'id',
                height: 440,
                singleSelect: true,
                toolbar: toolbar_choice,
                autoRowHeight: false,
                url: '/FrAnalysisChoiceManagement/GetFrChoiceJsonByID?id=' + '@Model.ToString()' + '&t=' + Math.random(),
                columns: [[
                    { field: 'title', title: '题目', width: ($(document.body).width() - 215) * 0.70, align: 'left',
                        styler: function (value, row, index) {
                            return 'overflow:hidden;white-space:nowrap;text-overflow: ellipsis;';
                        }
                    },
                    { field: 'answer_key', title: '答案', width: ($(document.body).width() - 180) * 0.15, align: 'center' },
                    { field: 'add_person', title: '添加人', width: ($(document.body).width() - 190) * 0.15, align: 'center' },
                    {
                        field: 'operation', title: '操作', width: 170, align: 'center',
                        formatter: function (value, rowData) {
                            var s = '<img src="/contents/images/admin/delete.png" align="middle""/>&nbsp;<a href="#" onclick="deleteChoice(\'' + rowData.id + '\')" title="删除" style="color:blue;margin-left:5px; margin-right:5px;text-decoration: none;">删除</a>';
                            s += '&nbsp;|&nbsp;&nbsp;&nbsp;<img src="/contents/images/admin/pencil.png" align="middle"/>&nbsp;<a href="#" onclick="showUpdateChoiceForm(\'' + rowData.id + '\')" title="修改" style="color:blue;margin-left:5px; margin-right:5px;text-decoration: none;">修改</a>';
                            return s;
                        }
                    }
	            ]],
                rowStyler: function (index, row) {
                    return 'height:35px;';
                },
                rownumbers: true,
                singleSelect: true,
                pagination: true,
                onLoadSuccess: function (data) {
                    if (data.rows.length == 0) {
                        var body = $(this).data().datagrid.dc.body2;
                        body.find('table tbody').html('<tr><td colspan="5" width="' + body.width() + '" style="height: 25px; text-align: center;">没有数据</td></tr>');
                    }
                }
            });
        });

        function showAddChoiceForm(id) {
            var addForm = {
                title: "添加选择题",
                width: 460,
                height: 445,
                templete: "<form action='' method='get' class='formClass'>" +
                            "<table width='100%'>" +
                            "<tr>" +
                            "<td align='left' valign='top'><iframe src='/FrAnalysisChoiceManagement/AddChoiceView?id=" + id.toString() + "&t=" + Math.random() + "'width='450' height='395'  marginwidth='0' marginheight='0' frameborder='0' allowtransparency='true'></iframe></td>" +
	                        "</tr>" +
                            "</table>" +
                            "</form>"
            }
            Shade.show(addForm);
        }
        function showUpdateChoiceForm(id) {
            var updateForm = {
                title: "修改选择题",
                width: 460,
                height: 445,
                templete: "<form action='' method='get' class='formClass'>" +
                            "<table width='100%'>" +
                            "<tr>" +
                            "<td align='left' valign='top'><iframe src='/FrAnalysisChoiceManagement/UpdateChoiceView?id=" + id.toString() + "&t=" + Math.random() + "'width='450' height='395'  marginwidth='0' marginheight='0' frameborder='0' allowtransparency='true'></iframe></td>" +
	                        "</tr>" +
                            "</table>" +
                            "</form>"
            }
            Shade.show(updateForm);
        }

        function closeShade() {
            Shade.hidden();
        }

        function deleteChoice(id) {
            $.ajax({
                type: 'GET',
                url: '/FrAnalysisChoiceManagement/DeleteChoice?t=' + Math.random(),
                data: { id: id },
                success: function (data) {
                    if (data == "0") {
                        alert("出现未知异常导致删除失败,请重试!");
                    }
                    else if (data == "1") {
                        $('#dg_choice').datagrid({
                            url: '/FrAnalysisChoiceManagement/GetFrChoiceJsonByID?id=' + '@Model.ToString()' + '&t=' + Math.random()
                        });
                    }
                }
            });
        }

        // 添加 、 修改 、删除时刷新列表
        function reloadDG() {
            Shade.hidden();
            $('#dg_choice').datagrid({
                url: '/FrAnalysisChoiceManagement/GetFrChoiceJsonByID?id=' + '@Model.ToString()' + '&t=' + Math.random()
            });
        }
    </script>
</body>
</html>
